package com.itheima.网络编程.网络编程基础编程.udp;

import java.io.IOException;
import java.net.*;

public class udp发送数据 {
    public static void main(String[] args) throws IOException {
        //udpSend1();
        udpSend2();

    }

    private static void udpSend2() throws IOException {
        DatagramSocket ds=new DatagramSocket();
        byte[] bys="hello wodld ..........".getBytes();
        DatagramPacket dp=new DatagramPacket(bys,bys.length,InetAddress.getByName("127.0.0.1"),10088);
        ds.send(dp);
        ds.close();
    }

    public static void udpSend1() throws IOException {
        DatagramSocket dgs=new DatagramSocket();
        byte[] bys="hello world ....".getBytes();
        DatagramPacket dgp=new DatagramPacket(bys,bys.length, InetAddress.getByName("127.0.0.1"),10086);
        dgs.send(dgp);
        dgs.close();
    }
}
